﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PrintAuto_AJRG.aspx.cs" Inherits="IYAKASAPortal.PrintAll.PrintAuto_AJRG" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>机动车安全技术检验表(人工检验部分)</title>
    <link rel="stylesheet" href="../support/tfNiceTable/tfNiceTable.css"/>
    <script type="text/javascript" src="../script/jquery-3.2.1.min.js"></script>
</head>
 <body style="overflow-y:auto">
 <form id="form2" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
    <div style="text-align:left; float:left; width:100%;height:1000px">
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <CR:CrystalReportViewer ID="CRAJ" runat="server"  PrintMode="ActiveX"  ToolPanelWidth="200px" Width="500px" DisplayStatusbar="False" HasCrystalLogo="False" HasGotoPageButton="False" HasSearchButton="False" HasToggleGroupTreeButton="False" HasToggleParameterPanelButton="False" ToolPanelView="None" />
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
         <br />
    </div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>

<script>

    window.onload = function ()
    {
        var str = document.getElementsByTagName('iframe');

        var ifmId = str[0].id;
        console.log(str[0].id);
     

        var headStr = "<html><head></head>"

        var footerStr = "</html>"
       // $(document.getElementById(ifmId).contentWindow.document.body).prepend("<OBJECT ID='WebBrowser' NAME='WebBrowser' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></OBJECT>");
        var s = $(document.getElementById(ifmId).contentWindow.document.body).html();
        console.log(s);

        document.body.innerHTML = headStr + s;

        document.body.insertAdjacentHTML("beforeEnd","<object id=\"WebBrowser\" width=0 height=0 \classid=\"clsid:8856F961-340A-11D0-A96B-00C04FD705A2\">");
        console.log("开始打印");
        document.all.WebBrowser.ExecWB(6, 2);
        
        console.log("打印结束");
        setTimeout('document.all.WebBrowser.ExecWB(45,1)',6000);
       
    }

   
</script>